package com.ytf.core.web.pojo.converter;

import com.ytf.core.web.pojo.dto.UserDto;
import com.ytf.core.web.pojo.model.User;
import com.ytf.core.web.pojo.vo.UserVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author YTF
 * @className RoleConverter
 * @date 2025/5/21 16:25
 * @description 用户实体类转换器
 */
@Mapper(componentModel = "spring")
public interface UserConverter {

    UserConverter INSTANCE = Mappers.getMapper(UserConverter.class);

    @Mapping(target = "id", ignore = true)  // DTO转Entity时忽略id
    @Mapping(target = "createTime", ignore = true) // 创建时间由数据库自动生成
    @Mapping(target = "updateTime", ignore = true) // 创建时间由数据库自动生成
    User userDtoToUser(UserDto dto);

    UserVo userToUserVo(User user);
}
